package com.glory.cqaospda.view

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Message
import android.view.KeyEvent
import android.view.View
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.glory.cqaospda.R
import com.glory.cqaospda.adapter.FixtureBindAdapter
import com.glory.cqaospda.adapter.LotProgramAdapter
import com.glory.cqaospda.adapter.MateriaAdapter
import com.glory.cqaospda.adapter.RealTimeAdapter
import com.glory.cqaospda.base.Constant
import com.glory.cqaospda.base.MyApp
import com.glory.cqaospda.bean.*
import com.glory.cqaospda.viewmodel.Startjob2Model
import com.glory.mvvmnet.base.BaseActivity
import com.glory.mvvmnet.entity.ToastMessageBean
import com.google.gson.JsonObject
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_ActivityManager
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_LogUtils
import kotlinx.android.synthetic.main.activity_endrun.*
import kotlinx.android.synthetic.main.activity_startjob2.*
import kotlinx.android.synthetic.main.activity_title.*
import kotlinx.android.synthetic.main.carrier_layout.*
import kotlinx.android.synthetic.main.carrier_layout.linear
import kotlinx.android.synthetic.main.carrier_layout.rvLotList
import kotlinx.android.synthetic.main.carriertape_layout.*
import kotlinx.android.synthetic.main.cover_layout.*
import kotlinx.android.synthetic.main.lotend_layout.*
import kotlinx.android.synthetic.main.plug_layout.*
import kotlinx.android.synthetic.main.reel_layout.*
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.ArrayList


class Startjob2Activity : BaseActivity<Startjob2Model>() {

    var pasnum = ""
    var mark = ""
    var lead = ""
    private var isend = ""

    //    private var lotState = ""
    private lateinit var lotList: ArrayList<LotInfoBean>
    private lateinit var mLotList: ArrayList<LotInfoBean>
    var runLotHiBeanList = ArrayList<RunLotHiBean>()
    var mFixtureBindAdapter: FixtureBindAdapter? = null
    var mLotProgramAdapter: LotProgramAdapter? = null
    var mRealTimeAdapter: RealTimeAdapter? = null
    var lotInfoBean: LotInfoBean? = null
    var resultData: ResultData? = null
    var isOne = true
    var type: String = ""
    var lotid: String = ""
    var eqpId: String = ""
    var stepName: String = ""
    var handler: Handler = object : Handler() {
        @SuppressLint("HandlerLeak")
        override fun handleMessage(msg: Message) {
            when (msg.what) {
                0x10 -> {
                    var s: String = msg.obj as String
                    val intent = Intent()
                    intent.putExtra("type", "Error")
                    intent.putExtra("error", s)
                    val clazz = Class.forName("com.glory.cqaospda.view.SkipDialogActivity")
                    intent.setClass(this@Startjob2Activity, clazz)
                    startActivity(intent)
                }
            }
            super.handleMessage(msg)
        }
    }

    override fun initData() {
        val date = Date()
        val dateFormat = SimpleDateFormat("yyyy-MM-dd hh:mm")

        val tipe = intent.getStringExtra("tipe").toString()

        val timeData = RealTimeBean()
        timeData.time = dateFormat.format(date)
        timeData.data = tipe
        val timeDataList = ArrayList<RealTimeBean>()
        timeDataList.add(timeData)

        initRecyclerView(rvRealTimeLog, this)
        mRealTimeAdapter = RealTimeAdapter(timeDataList)
        rvRealTimeLog.adapter = mRealTimeAdapter

        tvBaseSubmit.setOnClickListener {
            if (Constant.isFastClick()) {
                    val data = mFixtureBindAdapter!!.data
                    FreeApi_LogUtils.saveErrorMessages(data.toString(), "mFixtureBindAdapter")

                    for (s in data) {
                        if (s.mState != "End") {
                            viewModel.defUI.toastEvent.value = ToastMessageBean("当前有Lot未停止", false)
                            return@setOnClickListener
                        }
                    }
                    //Idle/TrackIn/Start/Stop/End/EndRun/TrackOut
                    val intent = Intent()
                    intent.putExtra("type", "EndRun")
                    intent.setClass(this, SkipDialogActivity::class.java)
                    startActivityForResult(intent, 1)
            }
        }

//        tvTemporary.setOnClickListener{
//            viewModel.defaultRunLotHis(
//                "1",
//                stepName,
//                "Start",
//                lotid,
//                lotInfoBean!!.mLotId,
//                eqpId,
//                pasnum, "", ""
//            )
//            isend = ""
//        }
        tvStart.setOnClickListener{
            viewModel.defaultRunLotHis(
                if (cbTemporary.isChecked)"1" else "0",
                stepName,
                "Start",
                lotid,
                lotInfoBean!!.mLotId,
                eqpId,
                pasnum, "", "",
                cbNewLot.isChecked
            )
            cbTemporary.isChecked = false
            cbNewLot.isChecked = false
            isend = ""
        }

        viewModel.defUI.callObserve.observe(this@Startjob2Activity) {
            if (!Constant.okgoError) {
                when (it.type) {
                    1 -> {
                        tvBaseSubmit.visibility = View.VISIBLE
                        llStart.visibility = View.GONE
                        cbTemporary.visibility = View.GONE
                        cbNewLot.visibility = View.GONE
                        tvBaseSubmit.text = "EndRun"
                        tvTitle.text = ""
                        tvstepNameTitle.text = stepName + "站点开始成功"
                        lineMarkingCode.visibility = View.GONE
                        lineProgramList1.visibility = View.GONE
                        lineProgramList2.visibility = View.GONE
                        rvProgramList.visibility = View.GONE
                        linear.visibility = View.GONE
                        rvLotList.visibility = View.VISIBLE

                        viewModel.defUI.toastEvent.value = ToastMessageBean("成功", true)
                        isOne = false
                        viewModel.defaultLotInfo(lotid, eqpId)

                    }
                    2 -> {

                        val runLotHiBean = it.item as RunLotHiBean
                        tvTitle.text = ""

                        tvstepNameTitle.text = stepName + "站点结束成功"

                        isend = "end"
                        isOne = false
                        if (stepName == "FT") {
                            runLotHiBeanList.add(runLotHiBean)
                            intent.putExtra("runLotHiBeanList", runLotHiBeanList)
                            intent.putExtra("EquipmentName", tvHandle.text.toString())
                            intent.putExtra("EquipmentStatus", tvMESstate.text)
                            intent.putExtra("mark", mark)
                            intent.putExtra("lead", lead)
                            intent.setClass(this, LotEndActivity::class.java)
                            startActivity(intent)
                            viewModel.defaultLotInfo(lotid, eqpId)
                        } else {
                            viewModel.defaultLotInfo(lotid, eqpId)
                        }


                    }
                    3 -> {
                        tvBaseSubmit.text = "EndRun"
                        tvTitle.text = ""
                        tvstepNameTitle.text = stepName + "站点暂停成功"

                        lineMarkingCode.visibility = View.GONE
                        linear.visibility = View.GONE
                        rvLotList.visibility = View.VISIBLE
                        viewModel.defUI.toastEvent.value = ToastMessageBean("成功", true)
                        isOne = false
                        viewModel.defaultLotInfo(lotid, eqpId)

                    }
                    4 -> {
//                        viewModel.defUI.toastEvent.value = ToastMessageBean("结束成功", true)
                        val endrun = it.item as EndRunBean
                        if (endrun.yield == null || endrun.yield == ""){
                            intent.setClass(this, HomeActivity::class.java)
                            startActivity(intent)
                            finish()
                        }else{
                            intent.putExtra("type", "EndRunBean")
                            intent.putExtra("inputqty", endrun.inputqty)
                            intent.putExtra("outputqty", endrun.outputqty)
                            intent.putExtra("yield", endrun.yield)
                            intent.putExtra("remark", endrun.remark)
                            intent.setClass(this, SkipDialogActivity::class.java)
                            startActivityForResult(intent, 1)
                        }

                    }
                    5 -> {
                        val lotsBean = it.item as LotInfoBean
                        FreeApi_LogUtils.saveErrorMessages(
                            lotsBean.toString(),
                            "CallObserve----LotInfoBean"
                        )
                        tvDevice.text = lotsBean.mCustomerDevice
                        tvPackage.text = lotsBean.mFactoryPackage
                        tvCustomerName.text = lotsBean.mCustomerName
                        if (isOne) {
                            lotsBean.mProcessingStatus = "Start"
                            if (!mLotList.contains(lotsBean)){
                                mLotList.add(lotsBean)
                            }
                            mFixtureBindAdapter!!.setList(mLotList)
                        }
                        for (i in 0..mLotList.size - 1) {
                            if (lotsBean.mLotId.equals(mFixtureBindAdapter!!.data[i].mLotId)) {
                                mLotList[i] = lotsBean
                            }
                        }

                        mFixtureBindAdapter!!.setList(mLotList)

                    }
                    6 -> {
                        val finaltestprogramBean = it.item as FinalTestProgramBean
                        lineProgramList1.visibility = View.VISIBLE
                        lineProgramList2.visibility = View.VISIBLE
                        rvProgramList.visibility = View.VISIBLE

                        initRecyclerView(rvProgramList, this)
                        mLotProgramAdapter = LotProgramAdapter(finaltestprogramBean.mProgramList)
                        rvProgramList.adapter = mLotProgramAdapter
//                    mLotProgramAdapter!!.notifyDataSetChanged()
                    }
                    7 -> {
                        Constant.eqpMaterialsBean = it.item as EqpMaterialsBean
                        materialsData()
                    }
                    8 ->{
                        resultData = it.item as ResultData
                        intent.putExtra("pass", resultData!!.pass)
                        intent.putExtra("mark", resultData!!.mark)
                        intent.putExtra("lead", resultData!!.lead)
                        lotid = lotInfoBean!!.mLotId
                        intent.putExtra("type", "End")
                        intent.putExtra("LotQty", lotInfoBean!!.mLotQty)
                        intent.setClass(this, SkipDialogActivity::class.java)
                        startActivityForResult(intent, 1)
                    }
                }
            } else {
                Constant.okgoError = false
            }
        }

        tvSetTrackOutNum.setOnClickListener {
            if (Constant.isFastClick()) {
                intent.putExtra("TypeActivity", "Startjob2")
                intent.putExtra("eqpID", eqpId)
                val clazz = Class.forName("com.glory.cqaospda.view.MaterialReplaceActivity")
                intent.setClass(this, clazz)
                startActivity(intent)
            }
        }
    }

    override fun initView(savedInstanceState: Bundle?) {
        linear.visibility = View.GONE
        tvBaseSubmit.text = "EndRun"
        tvUserName.text = Constant.UserName
        FreeApi_ActivityManager.getActivityManager().addActivity(this)

        val instance = MyApp.instance
        instance!!.handler = handler
        tvCustomerName.text = intent.getStringExtra("CustomerName").toString()
        tvPackage.text = intent.getStringExtra("FactoryPackage").toString()
        tvDevice.text = intent.getStringExtra("CustomerDevice").toString()
        tvHandle.text = intent.getStringExtra("EquipmentName").toString()
        tvEAPstate.text = intent.getStringExtra("EquipmentStatus").toString()
        tvMESstate.text = intent.getStringExtra("EquipmentStatus").toString()
        eqpId = intent.getStringExtra("eqpId").toString()
        lotid = intent.getStringExtra("LotId").toString()
        mLotList = ArrayList()
        lotList = intent.getSerializableExtra("lotList") as ArrayList<LotInfoBean>
        if (lotList == null) {
            if (lotid == null || lotid == "") {
                lotid = lotList[0].mLotId
            } else {
                lotList.clear()
                viewModel.defaultLotInfo(lotid, eqpId)
            }
        }

        for (s in lotList) {
            viewModel.defaultLotInfo(s.mLotId, eqpId)
        }
        lotid = lotList[0].mLotId
        materialsData()
        initRecyclerView(rvLotList, this)
        mFixtureBindAdapter = FixtureBindAdapter(null, true, "", "Start")
        rvLotList.setAdapter(mFixtureBindAdapter)
        mFixtureBindAdapter!!.setOnItemClickListener { it, lotInfoBean ->
            if (Constant.isFastClick()) {
                when (it) {
                    "State" -> {
                        this.lotInfoBean = lotInfoBean
                        lotid = lotInfoBean.mLotId
                        val intent = Intent()
                        intent.putExtra("type", "SelectSite")
                        intent.putExtra("lotId", lotid)
                        intent.putExtra("Action", "Start")
                        intent.putExtra("eqpId", eqpId)
                        intent.setClass(this, SkipDialogActivity::class.java)
                        startActivityForResult(intent, 1)
                    }
                    "stop" -> {
                        this.lotInfoBean = lotInfoBean
                        if (lotInfoBean.mStepName == null) {
                            viewModel.defUI.toastEvent.value =
                                ToastMessageBean("当前批次站点为空，无法暂停", false)
                            return@setOnItemClickListener
                        }
                        lotid = lotInfoBean.mLotId
                        intent.putExtra("type", "StepDesc")
                        intent.setClass(this, SkipDialogActivity::class.java)
                        startActivityForResult(intent, 1)
                    }
                    "End" -> {
                        if (lotInfoBean.mStepName == null) {
                            viewModel.defUI.toastEvent.value =
                                ToastMessageBean("当前批次站点为空，无法结束", false)
                            return@setOnItemClickListener
                        }
                        this.lotInfoBean = lotInfoBean
                        FreeApi_LogUtils.saveErrorMessages(
                            lotInfoBean.toString(),
                            "mFixtureBindAdapter"
                        )
                        lotid = lotInfoBean.mLotId
                        if (lotInfoBean.mTestMode != "FT") {
                            intent.putExtra("type", "Confirm")
                            intent.putExtra("LotQty", lotInfoBean.mLotQty)
                            intent.setClass(this, SkipDialogActivity::class.java)
                            startActivityForResult(intent, 1)
                        } else {
                            val map = JsonObject()
                            map.addProperty("LotNo",lotid)
                            map.addProperty("EquipmentName",eqpId)
                            viewModel.defaultGetResultData(map)
                        }
                    }
                }
            }
        }
        ivTypeArrow.setOnClickListener {
            if (lineMaterial.visibility == View.GONE) {
                ivTypeArrow.setImageResource(R.drawable.down)
                lineMaterial.visibility = View.VISIBLE
            } else {
                ivTypeArrow.setImageResource(R.drawable.left)
                lineMaterial.visibility = View.GONE
            }
        }
    }

    override fun layoutId(): Int {
        return R.layout.activity_startjob2
    }

    protected fun initRecyclerView(recyclerView: RecyclerView, context: Context?) {
        recyclerView.layoutManager = LinearLayoutManager(context)
        recyclerView.itemAnimator = DefaultItemAnimator()
        recyclerView.addItemDecoration(DividerItemDecoration(context, 1))
    }

    @SuppressLint("SetTextI18n")
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)

        if (requestCode == 1) {
            when (resultCode) {
                1 -> {
//                    lotState = "Stop"
                    val extras = data!!.getExtras()
                    stepName = extras!!.getString("StepName").toString()

                    lineMarkingCode.visibility = View.VISIBLE
                    tvMarkingCode1.text = lotInfoBean!!.mMarkingCode1
                    tvMarkingCode2.text = lotInfoBean!!.mMarkingCode2
                    tvMarkingCode3.text = lotInfoBean!!.mMarkingCode3
                    linear.visibility = View.GONE
                    rvLotList.visibility = View.GONE
                    tvBaseSubmit.visibility = View.GONE
                    llStart.visibility = View.VISIBLE
                    cbTemporary.visibility = View.VISIBLE
                    cbNewLot.visibility = View.VISIBLE
                    tvTitle.text = stepName + "站点"
                    viewModel.defaultFinalTestProgram(
                        lotid,
                        eqpId,
                        if (stepName == "") lotInfoBean!!.mTestMode else stepName
                    )
                }
                2 -> {
                    isend = ""
                    var mTestMode = ""
                    if (lotInfoBean!!.mTestMode == null) {
                        mTestMode = "FT"
                    } else {
                        mTestMode = lotInfoBean!!.mTestMode
                    }
                    if (stepName == null) {
                        stepName = ""
                    }
                    viewModel.defaultRunLotHis(
                        "",
                        if (stepName == "") mTestMode else stepName,
                        "Stop",
                        Constant.lotID,
                        lotInfoBean!!.mLotId,
                        eqpId,
                        pasnum, "", "",
                        cbNewLot.isChecked
                    )
//                    lotState = "End"

                }
                3 -> {
                    val extras = data!!.getExtras()
                    pasnum = extras!!.getString("pasnum").toString()
                    mark = extras.getString("mark").toString()
                    lead = extras.getString("lead").toString()
                    intent.putExtra("type", "Confirm")
                    intent.setClass(this, SkipDialogActivity::class.java)
                    startActivityForResult(intent, 1)
                }
                4 -> {
                    var mTestMode = ""
                    if (lotInfoBean!!.mTestMode == null) {
                        mTestMode = "FT"
                    } else {
                        mTestMode = lotInfoBean!!.mTestMode
                    }
                    if (stepName == null) {
                        stepName = ""
                    }
                    viewModel.defaultRunLotHis(
                        "",
                        if (stepName == "") mTestMode else stepName,
                        "End",
                        Constant.lotID,
                        lotInfoBean!!.mLotId, eqpId, pasnum, mark, lead,
                        cbNewLot.isChecked
                    )
//                    lotState = "End"
                }
                5 -> {

                    var pasnum = 0
//                    if (lotInfoBean == null){
//                        for (data in mFixtureBindAdapter!!.data){
//                            if (data.mSubLotList.isNotEmpty()) {
//                                for (num in lotInfoBean!!.mSubLotList) {
//                                    pasnum += num.mSubLotPassNumber.toInt()
//                                }
//                            }
//                        }
//                    }else{
//                        if (lotInfoBean!!.mSubLotList.isNotEmpty()) {
//                            for (num in lotInfoBean!!.mSubLotList) {
//                                pasnum += if(num.mSubLotPassNumber==null)0 else num.mSubLotPassNumber.toInt()
//                            }
//                        }
//                    }
                    if (Constant.eqpid != "") {
                        val map = JsonObject()
                        map.addProperty("LotNo", lotid)
                        map.addProperty("EquipmentName", Constant.eqpid)
                        map.addProperty("StepName", stepName)
                        map.addProperty("InputQty", 0)
                        viewModel.defaultEndRun(map)
                    } else {
                        viewModel.defUI.toastEvent.value =
                            ToastMessageBean("设备数据出现异常，请返回重新扫描设备！", false)
                    }
                }
                6 -> {
                    intent.setClass(this, HomeActivity::class.java)
                    startActivity(intent)
                    finish()
                }
                108 -> {
                    finish()
                }
            }

        }

    }

    override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            intent.putExtra("type", "KeyEvent")
            intent.setClass(this, SkipDialogActivity::class.java)
            startActivityForResult(intent, 1)
            return false
        }
        return super.onKeyUp(keyCode, event)
    }

    private fun materialsData() {

        val carriertapeData = filteringData("carriertape")

        initRecyclerView(rvCarrierList, this)
        val carriertapeAdapter = MateriaAdapter(carriertapeData, "carriertapeData")
        rvCarrierList.adapter = carriertapeAdapter
        if (carriertapeData.isEmpty()) {
            reCarriertape.visibility = View.GONE
        } else {
            reCarriertape.visibility = View.VISIBLE
        }
        carriertapeAdapter.setOnItemClickListener {data ->
            intent.putExtra("type", "materiaAdapter")
            intent.putExtra("materiaData", data)
            intent.setClass(this, SkipDialogActivity::class.java)
            startActivity(intent)
        }

        val reelData = filteringData("reel")
        initRecyclerView(rvReelList, this)
        val reelDataAdapter = MateriaAdapter(reelData, "reelData")
        rvReelList.adapter = reelDataAdapter
        if (reelData.isEmpty()) {
            reReel.visibility = View.GONE
        } else {
            reReel.visibility = View.VISIBLE
        }
        reelDataAdapter.setOnItemClickListener {data ->
            intent.putExtra("type", "materiaAdapter")
            intent.putExtra("materiaData", data)
            intent.setClass(this, SkipDialogActivity::class.java)
            startActivity(intent)
        }

        val coverData = filteringData("cover")
        initRecyclerView(rvCoverList, this)
        val coverDataAdapter = MateriaAdapter(coverData, "coverData")
        rvCoverList.adapter = coverDataAdapter
        if (coverData.isEmpty()) {
            reCover.visibility = View.GONE
        } else {
            reCover.visibility = View.VISIBLE
        }
        coverDataAdapter.setOnItemClickListener {data ->
            intent.putExtra("type", "materiaAdapter")
            intent.putExtra("materiaData", data)
            intent.setClass(this, SkipDialogActivity::class.java)
            startActivity(intent)
        }

        val plugData = filteringData("plug")
        initRecyclerView(rvPlugList, this)
        val plugDataAdapter = MateriaAdapter(plugData, "plugData")
        rvPlugList.adapter = plugDataAdapter
        if (plugData.isEmpty()) {
            rePlug.visibility = View.GONE
        } else {
            rePlug.visibility = View.VISIBLE
        }
        plugDataAdapter.setOnItemClickListener {data ->
            intent.putExtra("type", "materiaAdapter")
            intent.putExtra("materiaData", data)
            intent.setClass(this, SkipDialogActivity::class.java)
            startActivity(intent)
        }

    }

    private fun filteringData(type: String): List<EqpMaterialsBean.Materialslist?> {
        val mEntity: MutableList<EqpMaterialsBean.Materialslist?> = ArrayList()

        when (type) {
            "carriertape" -> {
                if (Constant.eqpMaterialsBean != null && Constant.eqpMaterialsBean!!.mMaterialslist != null) {
                    for (s in Constant.eqpMaterialsBean!!.mMaterialslist!!) {
                        if (s!!.mMaterialId != null) {
                            val substring = s!!.mMaterialId!!.substring(0, 3)
                            val substring2 = s.mMaterialId!!.substring(0, 2)
                            if (substring.equals("A04") || substring2.equals("04")) {
                                mEntity.add(s)
                            }
                        }
                    }
                } else {
                    viewModel.defUI.toastEvent.value = ToastMessageBean("当前物料为空", false)
                }
            }
            "reel" -> {
                if (Constant.eqpMaterialsBean != null && Constant.eqpMaterialsBean!!.mMaterialslist != null) {
                    for (s in Constant.eqpMaterialsBean!!.mMaterialslist!!) {
                        if (s!!.mMaterialId != null) {
                            val substring = s.mMaterialId!!.substring(0, 3)
                            val substring2 = s.mMaterialId!!.substring(0, 2)
                            if (substring.equals("A06") || substring2.equals("06")) {
                                mEntity.add(s)
                            }
                        }
                    }
                } else {
                    viewModel.defUI.toastEvent.value = ToastMessageBean("当前物料为空", false)
                }
            }
            "cover" -> {
                if (Constant.eqpMaterialsBean != null && Constant.eqpMaterialsBean!!.mMaterialslist != null) {
                    for (s in Constant.eqpMaterialsBean!!.mMaterialslist!!) {
                        if (s!!.mMaterialId != null) {
                            val substring = s.mMaterialId!!.substring(0, 5)
                            val substring2 = s.mMaterialId!!.substring(0, 4)
                            if (substring.equals("A0500") || substring2.equals("0500")) {
                                mEntity.add(s)
                            }
                        }
                    }
                } else {
                    viewModel.defUI.toastEvent.value = ToastMessageBean("当前物料为空", false)
                }
            }
            "plug" -> {
                if (Constant.eqpMaterialsBean != null && Constant.eqpMaterialsBean!!.mMaterialslist != null) {
                    for (s in Constant.eqpMaterialsBean!!.mMaterialslist!!) {
                        if (s!!.mMaterialId != null) {
                            val substring = s.mMaterialId!!.substring(3, 5)
                            val ss = s.mMaterialId!!.substring(0, 3)
                            val substring2 = s.mMaterialId!!.substring(2, 4)
                            val ss2 = s.mMaterialId!!.substring(0, 2)
                            if ((ss == "A05" && substring != "00") || (ss2 == "05" && substring2 != "00")) {
                                mEntity.add(s)
                            }
                        }
                    }
                } else {
                    viewModel.defUI.toastEvent.value = ToastMessageBean("当前物料为空", false)
                }
            }
        }
        return mEntity
    }


    override fun onRestart() {
        super.onRestart()
        if (Constant.eqpid != "") {
            viewModel.defaultEqpMaterials(Constant.eqpid)
        }
    }

}